<template>
	<p>{{time}}</p>
</template>
<script>
let timer = null
export default {
	name: 'HomeHeader',
	props: {},
	computed: {},
	watch: {},
	data () {
		return {
			time: ''
		}
	},
	methods: {
		getTime(){
			let date = new Date()
			let yy = date.getFullYear()
			let mm = this.utils.formatNum(date.getMonth()+1)
			let dd = this.utils.formatNum(date.getDate())
			let hh = this.utils.formatNum(date.getHours())
			let mf = this.utils.formatNum(date.getMinutes())
			let ss = this.utils.formatNum(date.getSeconds())
			let week = " 星期" + "日一二三四五六".charAt(date.getDay())
			this.time = yy+'年'+mm+'月'+dd+'日 '+hh+':'+mf+':'+ss + week
		}
	},
	created () {
		this.getTime()
		timer = setInterval(this.getTime,1000)
	},
	destroyed () {
		clearInterval(timer)
	}
}
</script>